import java.util.*;
public class of18 {
    public static void main(String[] args) {
        
    }
    public ListNode deleteNode(ListNode head, int val) {
        ListNode ld2 = head;
        if(head.next==null){
            return null;
        }
        ListNode ld1 = head.next;
        if(head.val==val){
            return ld1;
        }
        
        while(ld1.val!=val){
            ld1=ld1.next;
            ld2=ld2.next;
        }
        ld2.next=ld2.next;
        return head;

    }
}
